/*******************************************************************************
 * Copyright (c) 2008 CEA LIST.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA LIST - initial API and implementation
 *******************************************************************************/

package com.cea.papyrus.classdiagram.parsers.editorconfiguration;

import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.uml2.uml.OpaqueExpression;

import com.cea.papyrus.classdiagram.parsers.editorconfiguration.opaqueexpression.OpaqueExpressionSourceViewerconfiguration;
import com.cea.papyrus.extensionpoints.editors.configuration.DefaultDirectEditorConfiguration;
import com.cea.papyrus.umlutils.OpaqueExpressionUtil;

/**
 * 
 */
public class OpaqueExpressionConfigurationForVSL extends DefaultDirectEditorConfiguration  {

	/**
	 * Creates a new OpaqueExpressionConfigurationForVSL.
	 */
	public OpaqueExpressionConfigurationForVSL() {
	}
	
	/**
	 * {@inheritDoc}
	 */
	public SourceViewerConfiguration getSourceViewerConfiguration() {
		return new OpaqueExpressionSourceViewerconfiguration();
	}

	/**
	 * {@inheritDoc}
	 */
	public String getTextToEdit(Object editedObject) {
		if(editedObject instanceof OpaqueExpression) {
			return OpaqueExpressionUtil.getBodyForLanguage((OpaqueExpression)editedObject, getLanguage());
		}
		return "not an OpaqueExpression";
	}

	/**
	 * {@inheritDoc}
	 */
	public Object postEditAction(Object editedObject, String text) {
		if(editedObject instanceof OpaqueExpression) {
			OpaqueExpressionUtil.setBodyForLanguage((OpaqueExpression)editedObject, getLanguage(), text);
		}
		return null;
	}
}
